package com.mmd.common.component;

import com.mmd.utils.ObfuseTableBase64;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import java.util.Properties;

public class EncrypPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer{
	
	@Override
	protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
			Properties props) throws BeansException {
		String password = props.getProperty("jdbc.password");
		System.out.println("password=====" + password);
		if(password!=null){
			props.setProperty("jdbc.password", ObfuseTableBase64.doDecode(password));
		}
		super.processProperties(beanFactoryToProcess, props);
	}
	
	public static void main(String[] args) {
		System.out.println(ObfuseTableBase64.encode("yy7943RMB"));
	}
}
